<?php

class Admin_systemController extends Admin_baseController {

	public function indexAction() {

		$this->display();
	}

	// public function clearAction() {
	//     $str = "清理数据库\r\n";
	//     $str.= "----------------------------------------\r\n";
	//     $str.= "清理无效装修公司:\r\n";
	//     if($list = self::model('company')->getAll('status=2')) {
	//         $ids = [];
	//         foreach ($list as $row) {
	//             $str.="{$row['name']}...成功\r\n";
	//             $ids[] = $row['company_id'];
	//         }
	//         $ids = implode(',', $ids);
	//         self::model('user_favorite')->execute("delete from wf_user_favorite where type='company' and type_id in ({$ids})");
	//         self::model('company')->execute("delete from wf_company where company_id in {$ids}");
	//     }else{
	//         $str.="无公司需要清理";
	//     }
	//     $str.= "清理无效设计师:\r\n";
	//     if($list = self::model('decorator')->getAll('status=2 and role=1')) {
	//         $ids = [];
	//         foreach ($list as $row) {
	//             $str.="{$row['name']}...成功\r\n";
	//             $ids[] = $row['decorator_id'];
	//         }
	//         $ids = implode(',', $ids);
	//         $str.= "清理无效设计师案例:\r\n";
	//         if($case_list = self::model('decorator_case')->execute("select * form wf_decorator_case where decorator_id in ({$ids})")->fetchAll()) {
	//             $case_ids = [];
	//             foreach ($case_list as $row) {
	//                 $str.="{$row['title']}...成功\r\n";
	//                 $case_ids[] = $row['case_id'];
	//             }
	//             $case_ids = implode(',', $case_ids);
	//             self::model('user_favorite')->execute("delete from wf_user_favorite where type='design_case' and type_id in ({$case_ids})");
	//             self::model('decorator')->execute("delete from wf_decorator_case where case_id in {$case_ids}");
	//         }else{
	//             $str.="无设计师案例\r\n";
	//         }

	//         self::model('user_favorite')->execute("delete from wf_user_favorite where type='designer' and type_id in ({$ids})");
	//         self::model('decorator')->execute("delete from wf_decorator where decorator_id in {$ids}");
	//     }else{
	//         $str.="无设计师需要清理\r\n";
	//     }
	//     $str.= "清理无效验房师:\r\n";
	//     if($list = self::model('decorator')->getAll('status=2 and role=2')) {
	//         $ids = [];
	//         foreach ($list as $row) {
	//             $str.="{$row['name']}...成功\r\n";
	//             $ids[] = $row['decorator_id'];
	//         }
	//         $ids = implode(',', $ids);
	//         $str.= "清理无效验房师案例:\r\n";
	//         if($case_list = self::model('decorator_case')->execute("select * form wf_decorator_case where decorator_id in ({$ids})")->fetchAll()) {
	//             $case_ids = [];
	//             foreach ($case_list as $row) {
	//                 $str.="{$row['title']}...成功\r\n";
	//                 $case_ids[] = $row['case_id'];
	//             }
	//             $case_ids = implode(',', $case_ids);
	//             self::model('user_favorite')->execute("delete from wf_user_favorite where type='test_case' and type_id in ({$case_ids})");
	//             self::model('decorator')->execute("delete from wf_decorator_case where case_id in {$case_ids}");
	//         }else{
	//             $str.="无验房师案例\r\n";
	//         }
	//         self::model('user_favorite')->execute("delete from wf_user_favorite where type='tester' and type_id in ({$ids})");
	//         self::model('decorator')->execute("delete from wf_decorator where decorator_id in {$ids}");
	//     }else{
	//         $str.="无验房师需要清理\r\n";
	//     }
	//     $str.= "清理无效店铺:\r\n";
	//     if($list = self::model('shop')->getAll('status=2')) {
	//         $ids = [];
	//         foreach ($list as $row) {
	//             $str.="{$row['name']}...成功\r\n";
	//             $ids[] = $row['shop_id'];
	//         }
	//         $ids = implode(',', $ids);
	//         $str.= "清理无效店铺商品:\r\n";
	//         if($case_list = self::model('goods')->execute("select * form wf_goods where goods_id in ({$ids})")->fetchAll()) {
	//             $case_ids = [];
	//             foreach ($case_list as $row) {
	//                 $str.="{$row['name']}...成功\r\n";
	//                 $case_ids[] = $row['goods_id'];
	//             }
	//             $case_ids = implode(',', $case_ids);
	//             self::model('user_favorite')->execute("delete from wf_user_favorite where type='goods' and type_id in ({$case_ids})");
	//             self::model('goods')->execute("delete from wf_goods where goods_id in {$case_ids}");
	//         }else{
	//             $str.="无店铺商品清理\r\n";
	//         }
	//         self::model('user_favorite')->execute("delete from wf_user_favorite where type='shop' and type_id in ({$ids})");
	//         self::model('shop')->execute("delete from wf_shop where shop_id in {$ids}");
	//     }else{
	//         $str.="无店铺需要清理\r\n";
	//     }
	// }
}